/**
 * Created by shenhai on 15/9/7.
 */

var async = require('async');
var mysqlUtil = require('../../../common/utils/mysqlUtil');
var Region = mongoose.model('masterData_Regions');
/*  宝宝树66小区二次改造    add   gct  20170802   start   */
var Community = mongoose.model('community');
/*  宝宝树66小区二次改造    add   gct  20170802   end   */
exports.provinceService = function (req, callback) {

    var body = req.body;
    var option = {type: "province"};
    var sortType = {};

    Region.find(option, '_id name type').sort(sortType).exec(function (err, results) {
        callback(err, results);
    });
};


exports.cityService = function (req, callback) {

    var body = req.body;
    var option = {type: "city", parentId:body.provinceID};
    var sortType = {};

    Region.find(option, '_id name type').sort(sortType).exec(function (err, results) {
        callback(err, results);
    });
};


exports.countyService = function (req, callback) {

    var body = req.body;
    var option = {type: "county", parentId:body.cityID};
    var sortType = {};

    Region.find(option, '_id name type').sort(sortType).exec(function (err, results) {
        callback(err, results);
    });
};
/*  宝宝树66小区二次改造    add   gct  20170802   start   */
exports.villageService=function(req,callback)
{
    var body = req.body;
    var option = { countyId:body.countyId,isValid:true};
    var sortType = {};

    Community.find(option, '_id communityName').sort(sortType).exec(function (err, results) {
        callback(err, results);
    });
}
/*  宝宝树66小区二次改造    add   gct  20170802   end   */